<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>桥门机数据交换平台</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layui/css/skin.css" media="all">
    <link rel="stylesheet" href="../layui/css/table.css" media="all">
</head>
<body>
<div class="bup-header clear">
    <div class="bup-logo"><img src="../image/bup-logo.png"/></div>
    <div class="bup-title">
        <h3>桥门机数据交换平台</h3>
    </div>

</div>
<div class="table_div">

    <div class="layui-form-item">
        <div class="layui-input-inline " id="searchb">
            <button class="layui-btn" onclick="search()" id="search">查询</button>
        </div>

    </div>

    <table class="layui-table" id="uploadTable" lay-filter="uploadTable"></table>
</div>
</body>
<script type="text/javascript" src="../layui/layui.js"></script>
<script type="text/javascript" src="../layui/echarts.min.js"></script>
<script type="text/javascript" src="../layui/jquery.min.js"></script>
<script>
    var uploadTable;
    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table;
        uploadTable = table.render({
            elem: '#uploadTable'
            , url: '/NettyTcpServer/qm/findAll'
            , method: 'POST'
            , toolbar: '#toolbar' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter', 'print', 'exports']
            , cols: [[
                {type: 'checkbox'}
                , {field: 'device_code', title: '设备编号', align: "center", width: 180}
                , {field: 'big_carroute', title: '大车行程', align: "center", width: 120, edit: 'text'}
                , {field: 'main_hookheight', title: '主钩高度', align: "center", width: 100, edit: 'text'}
                , {field: 'reserved_vicehookheight', title: '预留副钩高度', align: "center", width: 150, edit: 'text'}
                , {field: 'main_hookload', title: '主钩吊重', align: "center", width: 95, edit: 'text'}
                , {field: 'reserved_vicehookload', title: '预留副钩吊重', align: "center", width: 120, edit: 'text'}
                , {field: 'small_carroute', title: '小车行程', align: "center", width: 95, edit: 'text'}
                , {field: 'reserved_smallcarroute', title: '预留小车2行程', align: "center", width: 120, edit: 'text'}
                , {field: 'wind_speed', title: '风速', align: "center", width: 70, edit: 'text'}
                , {
                    field: 'reserved_analogquantityone',
                    title: '预留模拟量1',
                    align: "center",
                    width: 95,
                    edit: 'text',
                    hide: "true"
                }
                , {
                    field: 'reserved_analogquantitytwo',
                    title: '预留模拟量2',
                    align: "center",
                    width: 110,
                    edit: 'text',
                    hide: "true"
                }
                , {
                    field: 'main_hookstatus',
                    title: '主钩载荷状态',
                    align: "center",
                    width: 120,
                    edit: 'text',
                    templet: function (item) {

                        if (item.main_hookstatus == '0') {
                            return "正常";
                        } else if (item.main_hookstatus == '1') {
                            return "超载";
                        }
                    }
                }
                , {
                    field: 'reserved_vicehookstatus',
                    title: '预留副钩载荷状态',
                    align: "center",
                    width: 140,
                    edit: 'text',
                    templet: function (item) {

                        if (item.reserved_vicehookstatus == '0') {
                            return "正常";
                        } else if (item.reserved_vicehookstatus == '1') {
                            return "超载";
                        }
                    }
                }
                , {
                    field: 'wind_speedalarm',
                    title: '风速报警',
                    align: "center",
                    width: 105,
                    edit: 'text',
                    templet: function (item) {
                        if (item.reserved_vicehookstatus == '0') {
                            return "正常";
                        } else if (item.reserved_vicehookstatus == '1') {
                            return "报警";
                        }
                    }
                }
                , {
                    field: 'big_carleftlimit',
                    title: '大车左限位',
                    align: "center",
                    width: 110,
                    edit: 'text',
                    templet: function (item) {
                        if (item.big_carleftlimit == '0') {
                            return "正常";
                        } else if (item.big_carleftlimit == '1') {
                            return "限位";
                        }
                    }
                }
                , {
                    field: 'big_carrightlimit', title: '大车右限位', align: "center", width: 105, edit: 'text',
                    templet: function (item) {
                        if (item.big_carrightlimit == '0') {
                            return "正常";
                        } else if (item.big_carrightlimit == '1') {
                            return "限位";
                        }
                    }
                }
                , {
                    field: 'small_carfrontlimit',
                    title: '小车前限位',
                    align: "center",
                    width: 105,
                    edit: 'text',
                    templet: function (item) {
                        if (item.small_carfrontlimit == '0') {
                            return "正常";
                        } else if (item.small_carfrontlimit == '1') {
                            return "限位";
                        }
                    }
                }
                , {
                    field: 'small_carbacklimit',
                    title: '小车后限位',
                    align: "center",
                    width: 110,
                    edit: 'text',
                    templet: function (item) {
                        if (item.small_carbacklimit == '0') {
                            return "正常";
                        } else if (item.small_carbacklimit == '1') {
                            return "限位";
                        }
                    }
                }
                , {
                    field: 'reserved_smallcarfrontlimit',
                    title: '预留小车2前限位',
                    // fixed: 'right',
                    align: "center",
                    width: 140,
                    edit: 'text',
                    templet: function (item) {

                        if (item.reserved_smallcarfrontlimit == '0') {
                            return "正常";
                        } else if (item.reserved_smallcarfrontlimit == '1') {
                            return "限位";
                        }
                    }
                }, {
                    field: 'reserved_smallcarbacklimit',
                    title: '预留小车2后限位',
                    // fixed: 'right',
                    align: "center",
                    width: 140,
                    edit: 'text',
                    templet: function (item) {

                        if (item.reserved_smallcarbacklimit == '0') {
                            return "正常";
                        } else if (item.reserved_smallcarbacklimit == '1') {
                            return "限位";
                        }
                    }
                }, {
                    field: 'hook_uplimit',
                    title: '吊钩上限位',
                    // fixed: 'right',
                    align: "center",
                    width: 105,
                    edit: 'text',
                    templet: function (item) {

                        if (item.hook_uplimit == '0') {
                            return "正常";
                        } else if (item.hook_uplimit == '1') {
                            return "限位";
                        }
                    }
                }, {
                    field: 'reserved_vicehookuplimit',
                    title: '预留副吊钩上限位',
                    // fixed: 'right',
                    align: "center",
                    width: 150,
                    edit: 'text',
                    templet: function (item) {

                        if (item.reserved_vicehookuplimit == '0') {
                            return "正常";
                        } else if (item.reserved_vicehookuplimit == '1') {
                            return "限位";
                        }
                    }
                }, {
                    field: 'door_limit',
                    title: '门限位',
                    // fixed: 'right',
                    align: "center",
                    width: 80,
                    edit: 'text',
                    templet: function (item) {

                        if (item.door_limit == '0') {
                            return "关闭";
                        } else if (item.door_limit == '1') {
                            return "打开";
                        }
                    }
                }, {
                    field: 'wind_antiskidstatus',
                    title: '抗风防滑状态',
                    // fixed: 'right',
                    align: "center",
                    width: 120,
                    edit: 'text',
                    templet: function (item) {

                        if (item.wind_antiskidstatus == '0') {
                            return "防护";
                        } else if (item.wind_antiskidstatus == '1') {
                            return "未防护";
                        }
                    }
                }, {
                    field: 'wire_drumstatus',
                    title: '电缆卷筒状态',
                    // fixed: 'right',
                    align: "center",
                    width: 130,
                    edit: 'text',
                    templet: function (item) {

                        if (item.wire_drumstatus == '0') {
                            return "正常";
                        } else if (item.wire_drumstatus == '1') {
                            return "故障";
                        }
                    }
                }, {
                    field: 'small_car1brake1',
                    title: '小车1制动器1',
                    // fixed: 'right',
                    align: "center",
                    width: 130,
                    edit: 'text',
                    templet: function (item) {
                        if (item.small_car1brake1 == '0') {
                            return "释放";
                        } else if (item.small_car1brake1 == '1') {
                            return "闭合";
                        }
                    }
                }, {
                    field: 'small_car1brake2',
                    title: '小车1制动器2',
                    // fixed: 'right',
                    align: "center",
                    width: 130,
                    edit: 'text',
                    templet: function (item) {

                        if (item.small_car1brake2 == '0') {
                            return "释放";
                        } else if (item.small_car1brake2 == '1') {
                            return "闭合";
                        }
                    }
                }, {
                    field: 'small_car2brake1',
                    title: '小车2制动器1',
                    // fixed: 'right',
                    align: "center",
                    width: 130,
                    edit: 'text',
                    templet: function (item) {

                        if (item.small_car2brake1 == '0') {
                            return "释放";
                        } else if (item.small_car2brake1 == '1') {
                            return "闭合";
                        }
                    }
                }, {
                    field: 'small_car2brake2',
                    title: '小车2制动器2',
                    // fixed: 'right',
                    align: "center",
                    width: 130,
                    edit: 'text',
                    templet: function (item) {

                        if (item.small_car2brake2 == '0') {
                            return "释放";
                        } else if (item.small_car2brake2 == '1') {
                            return "闭合";
                        }
                    }
                }, {
                    field: 'big_carLeg_deviation',
                    title: '大车支腿偏差',
                    // fixed: 'right',
                    align: "center",
                    width: 120,
                    edit: 'text'
                }, {
                    field: 'all_time',
                    title: '累计时间',
                    // fixed: 'right',
                    align: "center",
                    width: 100,
                    edit: 'text'
                }, {
                    field: 'all_times',
                    title: '循环使用次数',
                    // fixed: 'right',
                    align: "center",
                    width: 120,
                    edit: 'text'
                }, {
                    field: 'bigcar_ALM',
                    title: '支腿偏差报警',
                    // fixed: 'right',
                    align: "center",
                    width: 120,
                    edit: 'text',
                    templet: function (item) {

                        if (item.bigcar_ALM == '0') {
                            return "正常";
                        } else if (item.bigcar_ALM == '1') {
                            return "超偏差";
                        }
                    }
                }, {field: 'reserved_one', title: '预留1', align: "center", width: 95, edit: 'text',hide:true}
                , {field: 'reserved_two', title: '预留2', align: "center", width: 95, edit: 'text',hide:true}
            ]]
            , page: true
            , limit: '30'
            , height: 'full-200'
            , where: {
                "device_code": "2022031501"
            }

        });
        //监听单元格编辑
        table.on('edit(uploadTable)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            // layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改值为：' + value);
            $.post("/NettyTcpServer/qm/update", {"id": data.id, "field": field, "value": value}, function (obj) {
                layer.msg(obj, {time: 1000}, function () {
                });
            })
        });

    });


    //执行查询
    function search() {
        //这里以搜索为例
        uploadTable.reload({
            where: { //设定异步数据接口的额外参数，任意设
                device_code: "2022031501"
            },
            page: {
                curr: 1 //重新从第 1 页开始
            }
        })
    }
</script>
</html>